package com.zy.openchat.util;

import android.content.pm.PackageInfo;
import android.os.Build;

import com.zy.openchat.App;

import java.util.Locale;

import me.goldze.mvvmhabit.utils.MultiLanguageUtil;

public class System {
    public static String getAppLanguageEnv() {
        String language;
        int languageId = MultiLanguageUtil.getInstance().getLanguageId();
        if(languageId == MultiLanguageUtil.LANGUAGE_ENGLISH){
            language = "en";
        }else if(languageId == MultiLanguageUtil.LANGUAGE_CHINESE){
            language = "cn";
        }else{
            Locale l = Locale.getDefault();
            language = l.getLanguage();
            if ("zh".equals(language)) {//中文
                language = "cn";
            } else {//英语
                language = "en";
            }
        }
        return language;
    }

    public static String getAppVersionName() {
        String localVersion = "";
        try {
            PackageInfo packageInfo = App.getInstanse()
                    .getPackageManager()
                    .getPackageInfo(App.getInstanse().getPackageName(), 0);
            localVersion = packageInfo.versionName + "_" + packageInfo.versionCode;
        } catch (Exception e) {
        }
        return localVersion;
    }

    public static String getModel() {
        return Build.MANUFACTURER + "_" + Build.MODEL;
    }

    public static String getSysVersion() {
        return Build.VERSION.RELEASE;
    }
}
